package steed.ext.action.admin.wechat;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;

import steed.action.annotation.Power;
import steed.domain.wechat.WechatAccount;
import steed.ext.action.admin.DwzAdminAction;
import steed.ext.task.SynchronizationUsersTask;
@ParentPackage(value="steed")
@InterceptorRefs({@InterceptorRef(value="mydefault")})
@Namespace("/admin/wechat/wechatAccount")
@Power("管理微信公众号")
public class WechatAccountAction extends DwzAdminAction<WechatAccount>{
	private static final long serialVersionUID = 2917184309474601008L;
	
	@Action("index")
	@Power("查看微信公众号列表")
	public String index(){
		return super.index();
	}
	@Action("save")
	@Power("添加微信公众号")
	public String save(){
		synchronizaUser();
		return super.save();
	}
	private void synchronizaUser() {
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				new SynchronizationUsersTask().synchronizationUsers(getModel());
			}
		}).start();
	}
	
	@Action("add")
	@Power("添加微信公众号")
	public String add(){
		return super.add();
	}
	@Action("edit")
	@Power("编辑微信公众号")
	public String edit(){
		return super.edit();
	}
	@Action("update")
	@Power("编辑微信公众号")
	public String update(){
		synchronizaUser();
		return super.updateNotNullField();
	}
	
	
}
